import type { User } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

const useUserStore = defineStore(
  'cp-user',
  () => {
    const user = ref<User>()

    const saveUser = (newUser: User) => {
      user.value = newUser
    }

    const delUser = () => {
      user.value = undefined
    }

    return { user, saveUser, delUser }
  },
  { persist: true }
)

export { useUserStore }
